<?php

App::uses('AppModel', 'Model');

class Broker extends AppModel {

    public $validate = array(
        'company' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'Company is required'
            )
        ),
        'name' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'Name is required'
            ),
            'maxlength' => array(
                'rule' => array('maxLength', 45),
                'message' => 'Maximum 45 characters long'
            )
        ),
        'short_description' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'Short desciption is required'
            ),
            'maxlength' => array(
                'rule' => array('maxLength', 255),
                'message' => 'Maximum 255 characters long'
            )
        ),
        'order' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'Order is required'
            )
        ),
        'status' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'Status is required'
            )
        ),
        'date_added' => array(
            'required' => array(
                'rule' => array('notEmpty', 'date'),
                'message' => 'Date added is required'
            )
        )
    );

    public function beforeSave($options = array()) {
        $this->data[$this->alias]['date_added'] = date("Y-m-d H:i:s");
        return true;
    }

}
